package solutions;

import java.util.HashMap;
import java.util.Map;

import org.pi4.locutil.GeoPosition;
import org.pi4.locutil.MACAddress;
import org.pi4.locutil.trace.SignalStrengthSamples;
import org.pi4.locutil.trace.TraceEntry;

public class EntryWithMACsAndAverages implements
		Comparable<EntryWithMACsAndAverages> {

	public double distance;
	Map<MACAddress, Double> addresses = new HashMap<MACAddress, Double>();
	private final GeoPosition position;

	public EntryWithMACsAndAverages(TraceEntry entry) {
		this.position = entry.getGeoPosition();
		SignalStrengthSamples samples = entry.getSignalStrengthSamples();
		for (MACAddress address : samples.keySet()) {
			
			addresses.put(address, samples.getAverageSignalStrength(address));
		}
	}

	public EntryWithMACsAndAverages(GeoPosition position,
			Map<MACAddress, Double> wifiPositionsStrengths) {
		this.addresses = wifiPositionsStrengths;
		this.position = position;
	}

	@Override
	public int compareTo(EntryWithMACsAndAverages o) {
		if (this.distance > o.distance)
			return 1;
		else if (this.distance < o.distance)
			return -1;
		else
			return 0;
	}

	public GeoPosition getPosition() {
		return position;
	}
	
	public Map<MACAddress, Double> getAddressMap() {
		return addresses;
	}
}